package com.usian.ai.controller;

import com.alibaba.fastjson2.JSON;
import com.usian.ai.common.Result;
import com.usian.ai.pojo.Candidate;
import com.usian.ai.pojo.vo.CandidateReqVo;
import com.usian.ai.pojo.vo.CandidateSaveReqVo;
import com.usian.ai.service.CandidateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 12 05 11 26
 **/

@RestController
@RequestMapping("/candidate")
@CrossOrigin
@Slf4j
public class CandidateController {

   @Autowired
   CandidateService candidateService;


   @PostMapping("list")
   public Result list(@RequestBody CandidateReqVo candidateReqVo){

      log.info("info:candidateReqVo:{}", JSON.toJSONString(candidateReqVo));
      log.debug("debug:candidateReqVo:{}", JSON.toJSONString(candidateReqVo));
      log.warn("warn:candidateReqVo:{}", JSON.toJSONString(candidateReqVo));
      log.error("error:candidateReqVo:{}", JSON.toJSONString(candidateReqVo));

      return candidateService.listCandidate(candidateReqVo);
   }

   @PostMapping("saveCandidate")
   public Result saveCandidate(@RequestBody @Validated CandidateSaveReqVo candidateSaveReq){

      log.info("candidateSaveReq:{}", JSON.toJSONString(candidateSaveReq));
      return candidateService.saveCandidate(candidateSaveReq);
   }


}
